<template>
  <div class="safetyStatistics">
    <!-- 头部导航 -->
    <l-header :title="title"></l-header>
    <!-- tab -->
    <tab>
      <tab-item selected @on-item-click="onItemClick">总体统计</tab-item>
      <tab-item @on-item-click="onItemClick">单项统计</tab-item>
      <tab-item @on-item-click="onItemClick">排名汇总</tab-item>
    </tab>
    <div class="tabLine"><span id="transformLine"></span></div>

    <!-- 内容 -->
    <div class="container">
      <l-totality v-show="currentTab == '0'"></l-totality>
      <l-individual v-show="currentTab == '1'" ref="individual"></l-individual>
      <l-ranking v-show="currentTab == '2'"></l-ranking>
    </div>
  </div>
</template>
<script>
import lHeader from "./header";
import lTotality from "./totality";
import lIndividual from "./individual";
import lRanking from "./ranking";
export default {
  name: "safetyStatistics",
  data() {
    return {
      title: "安全统计",
      currentTab: 0
    };
  },
  mounted() {},
  components: { lHeader, lTotality, lIndividual, lRanking },
  methods: {
    onItemClick(index) {
      this.currentTab = index;
      console.log("选择tab:", index);
      let transformLine = document.getElementById("transformLine");
      if (index == 0) {
        transformLine.style.left = "14%";
      } else if (index == 1) {
        transformLine.style.left = "48%";
        this.$refs.individual.listFlag = true;
        this.$refs.individual.echartsFlag = false;
      } else if (index == 2) {
        transformLine.style.left = "81%";
      }
    }
  }
};
</script>
<style lang="less" scoped>
.safetyStatistics {
  height: 100%;
  background: #f5f5f5;
}
// 修正vux样式为ui需求
/deep/.vux-tab-container {
  height: 44px !important;
  box-shadow: none;
}
/deep/.vux-tab {
  height: 44px !important;
}
/deep/.vux-tab-item {
  line-height: 44px !important;
  color: #b3b5ba !important;
}
/deep/.vux-tab-ink-bar {
  //   background-color: transparent!important;
  display: none !important;
}
/deep/.vux-tab-wrap {
  padding-top: 0 !important;
}
// 修改tab底部线条
.tabLine {
  width: 100%;
  height: 3px;
  position: absolute;
  top: 85px;
  z-index: 501;
  span {
    display: block;
    width: 16px;
    height: 100%;
    background: #4d86ff;
    border-radius: 2px;
    position: absolute;
    left: 14%;
    transition: 0.5s ease;
  }
}
// 内容
.container {
  height: calc(~"100% - 88px");
  padding-top: 44px;
  overflow-y: scroll;
}
</style>
